package com.qdxwx.data.service.channel;

import com.qdxwx.data.mapper.channel.CompanyChannelMapper;
import com.qdxwx.models.channel.CompanyChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class CompanyChannelServiceImpl implements CompanyChannelService {

    @Autowired
    private CompanyChannelMapper companyChannelMapper;

    @Override
    public int insert(CompanyChannel companyChannel) {
        return companyChannelMapper.insertCompanyChannel(companyChannel);
    }

    @Override
    public int updateSort(CompanyChannel companyChannel) {
        if(companyChannel.getCompanyId() < 1 || companyChannel.getChannelId() < 1) return 0;
        return companyChannelMapper.updateSort(companyChannel);
    }

    @Override
    public int delete(int id) {
        return companyChannelMapper.deleteById(id);
    }

    @Override
    public int delete(int companyId, int channelId) {
        if(companyId < 1 || channelId < 1) return 0;
        CompanyChannel companyChannel = new CompanyChannel();
        companyChannel.setChannelId(channelId);
        companyChannel.setCompanyId(companyId);
        return companyChannelMapper.deleteByCompanyChannel(companyChannel);
    }

    @Override
    public List<CompanyChannel> getList(CompanyChannel companyChannel) {
        return companyChannelMapper.selectList(companyChannel);
    }
}
